private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        jTextArea2.setText("");
        long start = System.currentTimeMillis();
        StringTokenizer st = new StringTokenizer(jTextField2.getText(), "|");
        int N = Integer.parseInt(st.nextToken());
        jTextArea2.append("N=" + N + "\n");
        int tab[] = new int[N];//definire tablou
        //initializare tablou cu valoarea pozitiei
        for (int i = 0; i < N; i++) {
            tab[i] = i;
            jTextArea2.append(" ");
            jTextArea2.append(tab[i] + " ");
        }
        jTextArea2.append("\n");

        //String restsir=st.nextToken();
        StringTokenizer st1 = new StringTokenizer(st.nextToken(), " ");
        while (st1.hasMoreTokens()) {
            //String per=st1.nextToken();
            StringTokenizer stemp = new StringTokenizer(st1.nextToken(), "-");
            int p = Integer.parseInt(stemp.nextToken());
            int q = Integer.parseInt(stemp.nextToken());

            int px = p;
            while (px != tab[p]) {
                px = tab[p];
            }
            int qx = q;
            while (qx != tab[q]) {
                qx = tab[q];
            }
            if (px == qx) {
                jTextArea2.append("[" + p + " " + q + "]exista conexiunea ");
                jTextArea2.append("\n");
            } else {
                tab[p] = tab[q];
                jTextArea2.append("[" + p + " " + q + "] ");
                for (int i = 0; i < N; i++) {
                    jTextArea2.append(tab[i] + " ");
                }
                jTextArea2.append("\n");
            }
        }//while
        long end = System.currentTimeMillis();
        long timp = end - start;
        jLabel2.setText(Long.toString(timp));
    }